package Others;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class _506_RelativeRanks {
    public String[] findRelativeRanks(int[] nums) {
        String[] results = new String[nums.length];
        int[] numsCopy = Arrays.copyOf(nums, nums.length);
        Arrays.sort(numsCopy);
        Map<Integer, Integer> maps = new HashMap<Integer, Integer>();
        for (int i = 0; i < numsCopy.length; i++) {
            maps.put(numsCopy[i],numsCopy.length - i);
        }
        int count = 0;
        for (int i : nums) {
            if (i == numsCopy[nums.length-1]) {
                results[count] = "Gold Medal";
            } else if (i == numsCopy[nums.length-2]) {
                results[count] = "Silver Medal";
            } else if (i == numsCopy[nums.length-3]) {
                results[count] = "Bronze Medal";
            } else {
                results[count] = maps.get(i) + "";
            }
            count++;
        }
        return results;
    }
}
